<template>
  <div>
    <h2>博客预览</h2>
    <article-card v-for="(article, index) in articles" :key="index">
      <div slot="article-title">
        <el-link @click="onArticleLinkClick(article.id)"><span>{{ article.article_title }}</span></el-link>
      </div>
      <div slot="article-content">
        {{ article.article_content }}
      </div>
    </article-card>
  </div>
</template>

<script>
import ArticleCard from "@/views/blog/childComps/articles/ArticleCard";
import * as blogRequest from '@/network/blog'
export default {
  name: "BlogArticles",
  components: {
    ArticleCard,

  },
  data() {
    return {
      articles: null
    }
  },
  mounted() {
    blogRequest.getArticles().then(res=>{
      this.articles = res
      console.log(res)
    })
  },
  methods:{
    onArticleLinkClick(articleId){
      console.log("onArticleLinkClick");
      // this.$store.state.blogData.currentArticleId = articleId;
      this.$router.push('/blog/article_edit/'+articleId+'/');
    }
  }
}
</script>

<style scoped>

</style>
